# -*- coding: UTF-8 -*-

# default function
# formats % (var1, var2,....)
print "%d | %f | %s" % (2, 3.2, "str");


def cmd():
    import subprocess  # 执行系统命令行命令

    cmd = "cmd.exe";
    begin = 1;
    end = 5;
    
    while begin < end :
        try:
            p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE);
            p.stdin.write("ping 192.168.1." + str(begin) + "\n");
            
            p.stdin.close();
            p.wait();
        except Exception,e:
            print e;
        finally:
            print "execution result : %s " % p.stdout.read();
        
cmd();
